#encoding:utf-8
from functools import wraps
import config
from flask import session,redirect,url_for


# def login_required(func):
#     @wraps(func)
#     def wrapper(*args,**kwargs):
#         if config.CMS_USER_ID in session:
#             return func(*args,**kwargs)
#         else:
#             return redirect(url_for('cms.login'))
#     return wrapper

#判断是否登录，session 当中是否有前台用户的ID。
def login_required(func):
    @wraps(func)
    def wrapper(*args,**kwargs):
        if config.FRONT_USER_ID in session:
            return func(*args,**kwargs)
        else:
            return redirect(url_for('front.signin'))
    return wrapper